home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15615 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: rain.fr!world-net!usenet
  2. From: Juniet Christophe <chris@lmm.com>
  3. Newsgroups: comp.os.linux.setup,comp.os.linux.misc,comp.os.linux,comp.lang.c,comp.lang.c++
  4. Subject: Re: problems with GCC
  5. Date: Sat, 20 Apr 1996 13:33:56 +0200
  6. Organization: Le Monde Mobile
  7. Message-ID: <3178CBA4.2E841546@lmm.com>
  8. References: <4l1and$iql@news.ran.es>
  9. NNTP-Posting-Host: pm9-004.sct.fr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-8859-1
  12. Content-Transfer-Encoding: quoted-printable
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.13 i586)
  14.  
  15. Chano G=F3mez Mart=EDnez wrote:
  16. > =
  17.  
  18. > First of all, I want to apologize for my awful English.
  19.  
  20.   I should say the same ;^)
  21.  
  22. > Now, the C stuff :
  23. > =
  24.  
  25. > I'm trying to port a C program from Borland C++ 3.1 to GCC under
  26. > Linux.
  27. > My problem is that I can't use any function from math.h !!!
  28. > The file is correctly #include'd ( in fact, I get no compilation
  29. > errors ) but the linker always tells me something like :
  30. > =
  31.  
  32. > /tmp/cca000971.o(.text+0x39): undefined reference to `exp'
  33. > =
  34.  
  35. > The funny thing is that GPC ( the GNU Pascal compiler ) allows me to
  36. > use math.h functions lihe exp(), sin(), fabs(), etc, but when I
  37. > convert my Pascal programs to C with p2c and try to compile them with
  38. > GCC , I get the same error again.
  39. > =
  40.  
  41. > Here is the result from compiling the Pascal source with GPC -v ...
  42. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
  43. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
  44. >
  45. (...messages from gpc...)
  46.  
  47. > -L/usr/i486-linux/lib /tmp/cca001031.o -lgpc -lgcc -lm -lc -lg
  48. Here it is!                                         ^^^^^^
  49.  
  50. (...messages from gcc...)
  51. >
  52. > The only apparent difference between both results is in the libraries
  53. > ( I think)
  54. > Can anyone help me, please ???
  55. > =
  56.  
  57.  
  58. When you compile some code, you need to link it to the right libraries.
  59. For instance, you need to link your program with the library libm which
  60. is for math.
  61. Try `gcc ... -lm`. In general, for foo.h try -lfoo, but you'd better
  62. check /lib or /usr/lib.
  63.  
  64. >    Thanks in advance.
  65. Hope this helps :)
  66.  
  67. -- =
  68.  
  69. Christophe Juniet =
  70.  
  71. chris@lmm.com =
  72.  
  73. Un Linux, s'il vous pla=EEt!
  74. (A Linux, please!)
  75.